<!--  -->
<template>
  <div>
    <van-form @submit="changeFromData">
      <div class="font15 mt10 pl10">
        <span class="titletext ">{{ titledata.title }}</span>
        <div class="graytext  mt10 font13">
          <span>工单编号：</span>
          <span class="titletext">{{ titledata.pmInsId }}</span>
        </div>
      </div>
      <div v-if="!canEdit" class="font11 mt10 bggray ptandpb10">
        <div class=" graytext pl10">
          <span>商机填报人：</span>
          <span class="titletext">{{ fromdata.informant }}</span>
        </div>
        <div class="mt10 graytext pl10">
          <span>商机填报人联系方式：</span>
          <span class="titletext">{{ fromdata.informantPhone }}</span>
        </div>
        <div class="mt10 graytext pl10">
          <span>地市：</span>
          <span class="titletext">{{ fromdata.cities }}</span>
        </div>
        <div class="mt10 graytext pl10">
          <span>县区：</span>
          <span class="titletext">{{ fromdata.county }}</span>
        </div>
      </div>
      <div class="mt10" style=" display: flex;border-bottom: 1px solid #ebedf0;">
        <div class="blue_item"></div>
        <span class="font15" style="display: flex; line-height: 33px;margin-left:5px;  flex:1;">商机数据</span>
        <van-button v-show="canEdit" block type="info" style="display: inline-block;width:auto;height: 33px;"
          native-type="button" @click="choseSJ">选择关联商机</van-button>
      </div>
      <van-field readonly required input-align="left" label-width="4.5em" name="opportunitiesNumber"
        :value="fromdata.opportunitiesNumber" label="商机编号:" placeholder="请填写商机编号"
        :rules="[{ required: true, message: '' }]" />
      <van-field readonly required autosize type="textarea" input-align="left" label-width="4.5em"
        name="opportunitiesName" :value="fromdata.opportunitiesName" label="商机名称:" placeholder="请填写商机名称"
        :rules="[{ required: true, message: '' }]" />
      <van-field v-if="canEdit" readonly required input-align="left" label-width="2.5em" name="cities"
        :value="fromdata.cities" label="地市:" placeholder="请填写地市" :rules="[{ required: true, message: '' }]" />
      <van-field v-if="canEdit" readonly required input-align="left" label-width="2.5em" name="county"
        :value="fromdata.county" label="县区:" placeholder="请填写县区" :rules="[{ required: true, message: '' }]" />
      <van-field v-if="canEdit" readonly input-align="left" label-width="5.5em" name="informant"
        :value="fromdata.informant" label="商机填报人:" />
      <!-- <van-field v-if="canEdit" :readonly='!canEdit' required input-align="left" label-width="9.5em"
                name="informantPhone" v-model="fromdata.informantPhone" label="商机填报人联系方式:" :right-icon="canEdit?'arrow':''"
                 /> -->
      <myvan_field :canEdit="canEdit" :name='"informantPhone"' :model='fromdata.informantPhone' :label='"商机填报人联系方式:"'
        @freshData='freshData($event)' />
      <van-field readonly autosize type="textarea" rows="1" name="customerName" :value="fromdata.customerName" label="客户单位名称:" label-width="6.5em"/>
      <van-field readonly autosize type="textarea" rows="1" name="customerCode" :value="fromdata.customerCode" label="客户编码:" label-width="4.5em"/>
      <van-field readonly autosize type="textarea" rows="1" name="isProvStrategicCustomer" :value="fromdata.isProvStrategicCustomer=='1'?'是':fromdata.isProvStrategicCustomer=='0'?'否':''" label="是否省级战略客户:" label-width="8.5em"/>
      <van-field readonly autosize type="textarea" rows="1" name="isCityStrategicCustomer" :value="fromdata.isCityStrategicCustomer=='1'?'是':fromdata.isCityStrategicCustomer=='0'?'否':''" label="是否市级战略客户:" label-width="8.5em"/>
      <van-field readonly autosize type="textarea" rows="1" name="industryType" :value="fromdata.industryType" label="客户行业:" label-width="4.5em"/>
      <van-field readonly autosize type="textarea" rows="1" name="preAmount" :value="fromdata.preAmount" label="商机预估金额(万元):" label-width="9.5em"/>
      <van-field readonly input-align="left" label-width="4.5em" name="currentSituation"
        :value="fromdata.currentSituation" label="当前形势:" />
      <van-field readonly autosize type="textarea" input-align="left" label-width="4.5em" name="dictIntroduction"
        :value="fromdata.dictIntroduction" label="商机简介:" />
      <van-field readonly autosize type="textarea" input-align="left" label-width="4.5em" name="buildContent"
        :value="fromdata.buildContent" label="建设内容:" />
      <myvan_field :canEdit="canEdit" :name='"informantDepartment"' :model='fromdata.informantDepartment'
        :label='"填报人组织:"' :type="'textarea'" @freshData='freshData($event)' />
      <myvan_field :canEdit="canEdit" :name='"informantPosition"' :model='fromdata.informantPosition' :label='"填报人岗位:"'
        @freshData='freshData($event)' />
      <myvan_field :canEdit="canEdit" :name='"opportunitiesType"' :model='fromdata.opportunitiesType' :label='"商机类型:"'
        @freshData='freshData($event)' />
      <myvan_field :canEdit="canEdit" :name='"industryType"' :model='fromdata.industryType' :label='"行业类型:"'
        @freshData='freshData($event)' />
      <myvan_field :canEdit="canEdit" :name='"withType"' :model='fromdata.withType' :label='"业务类型:"'
        @freshData='freshData($event)' />
      <myvan_field :canEdit="canEdit" :name='"withBusiness"' :model='fromdata.withBusiness' :label='"业务场景:"'
        @freshData='freshData($event)' />
      <!-- <van-field :readonly='!canEdit' autosize type="textarea" input-align="left" label-width="5.5em"
                name="informantDepartment" v-model="fromdata.informantDepartment" label="填报人组织:" :right-icon="canEdit?'arrow':''"/>
        <van-field :readonly='!canEdit' input-align="left" label-width="5.5em"
                name="informantPosition" v-model="fromdata.informantPosition" label="填报人岗位:" :right-icon="canEdit?'arrow':''"/>
        <van-field :readonly='!canEdit' input-align="left" label-width="4.5em"
                name="opportunitiesType" v-model="fromdata.opportunitiesType" label="商机类型:" :right-icon="canEdit?'arrow':''"/>
        <van-field :readonly='!canEdit' input-align="left" label-width="4.5em"
                name="industryType" v-model="fromdata.industryType" label="行业类型:" :right-icon="canEdit?'arrow':''"/>
        <van-field :readonly='!canEdit' input-align="left" label-width="4.5em"
                name="withType" v-model="fromdata.withType" label="业务类型:" :right-icon="canEdit?'arrow':''"/>
        <van-field :readonly='!canEdit' input-align="left" label-width="4.5em"
                name="withBusiness" v-model="fromdata.withBusiness" label="业务场景:" :right-icon="canEdit?'arrow':''"/> -->
      <!-- 能力信息模块 -->
      <div class="mt10" style=" display: flex;border-bottom: 1px solid #ebedf0;">
        <div class="blue_item"></div>
        <span class="font15" style="display: flex; line-height: 33px;margin-left:5px;  flex:1;">能力信息</span>
      </div>
      <van-field readonly required name="abilityInformationState"
        :value="fromdata.abilityInformationState == true ? '是' : '否'" label="是否使用中台能力：" label-width="9em"
        :right-icon="canEdit ? 'arrow' : ''" @click="canEdit == true ? showPopView('abilityInformationState') : ''"
        placeholder="请选择是否使用中台能力" :rules="[{ required: canEdit, message: '' }]" />
      <div v-if="fromdata.abilityInformationState == true" class="mt10"
        style=" display: flex;border-bottom: 1px solid #ebedf0;">
        <div class="blue_item"></div>
        <span class="font15" style="display: flex; line-height: 33px;margin-left:5px;  flex:1;">能力名称</span>
        <van-button v-show="canEdit" block type="info" style="display: inline-block;width:auto;height: 33px;"
          native-type="button" @click="choseZTNL">选择中台能力</van-button>
      </div>
      <el-table v-if="fromdata.abilityInformationState == true" :data="fromdata.abilityInformationModeList" border
        style="width: 100%">
        <el-table-column prop="abilityProvider" label="能力提供方" />
        <el-table-column prop="abilityName" label="能力名称" />
        <el-table-column prop="abilityCode" label="能力编码" />
        <el-table-column label="操作">
          <template slot-scope="scope">
            <el-button v-if="canEdit" size="mini" type="danger" @click="handleDelete(scope.$index)">删除</el-button>
          </template>
        </el-table-column>
      </el-table>
      <van-field readonly required name="bigDataProductsState" :value="fromdata.bigDataProductsState == true ? '是' : '否'"
        label="是否使用大数据产品：" label-width="10em" :right-icon="canEdit ? 'arrow' : ''"
        @click="canEdit == true ? showPopView('bigDataProductsState') : ''" placeholder="请选择是否使用大数据产品"
        :rules="[{ required: canEdit, message: '' }]" />
      <div v-if="fromdata.bigDataProductsState == true" class="mt10"
        style=" display: flex;border-bottom: 1px solid #ebedf0;">
        <div class="blue_item"></div>
        <span class="font15" style="display: flex; line-height: 33px;margin-left:5px;  flex:1;">产品名称</span>
        <van-button v-show="canEdit" block type="info" style="display: inline-block;width:auto;height: 33px;"
          native-type="button" @click="choseDSJCP">选择大数据产品</van-button>
      </div>
      <el-table v-if="fromdata.bigDataProductsState == true" :data="fromdata.bigDataProductsModeList" border
        style="width: 100%">
        <el-table-column prop="firstClassProductName" label="一级产品名称" />
        <el-table-column prop="productClass" label="产品分类" />
        <el-table-column prop="maProductName" label="产品名称" />
        <el-table-column prop="tariffCode" label="资费代码" />
        <el-table-column prop="billingMode" label="计费模式" />
        <el-table-column label="操作">
          <template slot-scope="scope">
            <el-button v-if="canEdit" size="mini" type="danger" @click="handleDeletedsj(scope.$index)">删除</el-button>
          </template>
        </el-table-column>
      </el-table>
      <van-field readonly required name="abilityPrecipitate" :value="fromdata.abilityPrecipitate == true ? '是' : '否'"
        label="是否沉淀中台能力：" label-width="9em" :right-icon="canEdit ? 'arrow' : ''"
        @click="canEdit == true ? showPopView('abilityPrecipitate') : ''" placeholder="请选择是否沉淀中台能力"
        :rules="[{ required: canEdit, message: '' }]" />
      <!-- <van-field :readonly='!canEdit' name="abilityName" required v-model="fromdata.abilityName" label="能力名称：" label-width="5em"  :right-icon="canEdit?'arrow':''" placeholder="请填写能力名称" :rules="[{ required: canEdit, message: '' }]"/> -->
      <myvan_field v-if="fromdata.abilityPrecipitate == true" :canEdit='canEdit' :required='true' :name='"abilityName"'
        :model='fromdata.abilityName' :label='"能力名称："' :placeholder='"请填写能力名称"' @freshData='freshData($event)'
        :rules="[{ required: canEdit, message: '' }]" />
      <!-- <van-field :readonly='!canEdit' autosize type="textarea" required name="abilityIntroduce" v-model="fromdata.abilityIntroduce" label="能力介绍：" label-width="5em"  :right-icon="canEdit?'arrow':''" placeholder="请填写能力介绍" :rules="[{ required: canEdit, message: '' }]"/> -->
      <myvan_field v-if="fromdata.abilityPrecipitate == true" :canEdit='canEdit' :required='true'
        :name='"abilityIntroduce"' :model='fromdata.abilityIntroduce' :label='"能力介绍："' :placeholder='"请填写能力介绍"'
        @freshData='freshData($event)' :rules="[{ required: canEdit, message: '' }]" />
      <van-popup v-model='showPop' round position="bottom" get-container="body">
        <van-picker show-toolbar title="请选择" @cancel="showPop = false" :columns="showPopColumns"
          @confirm="UpAndDownPopConfirm" />
      </van-popup>
      <van-field readonly autosize type="textarea" rows="1" name="coverCloudNetWork5G" :value="fromdata.coverCloudNetWork5G" label="融云,网,5G情况:" label-width="7.5em"/>
      <van-field readonly autosize type="textarea" rows="1" name="coverPlatformContent" :value="fromdata.coverPlatformContent" label="融平台(含原子能力)情况:" label-width="11.5em"/>
      <van-field readonly autosize type="textarea" rows="1" name="coverAiContent" :value="fromdata.coverAiContent" label="融AI情况:" label-width="4.5em"/>
      <div class="mt10" style=" display: flex;border-bottom: 1px solid #ebedf0;">
        <div class="blue_item"></div>
        <span class="font15" style="display: flex; line-height: 33px;margin-left:5px;  flex:1;">补充数据</span>
      </div>
      <myvan_field :canEdit="canEdit" :required='true' :name='"demandPersonnel"' :model='fromdata.demandPersonnel'
        :label='"需求人员:"' @freshData='freshData($event)' :placeholder='"请填写需求人员"' />
      <myvan_field :required='true' :name='"supportType"' :model='fromdata.supportType' :label='"支撑类型:"'
        @freshData='freshData($event)' />
      <!-- <van-field readonly required input-align="left" label-width="4.5em"
                name="demandPersonnel" :value="fromdata.demandPersonnel" label="需求人员:"
                 />

        <van-field readonly required input-align="left" label-width="4.5em"
                name="supportType" :value="fromdata.supportType" label="支撑类型:"
                 /> -->
      <!-- <van-field readonly required input-align="left" label-width="4.5em"
                name="supportWay" :value="fromdata.supportWay" label="支撑方式:"
                /> -->
      <van-field readonly required name="supportWay" :value="fromdata.supportWay" label="支撑方式：" label-width="5em"
        placeholder="请选择" @click="canEdit ? showOptionDialog('supportWayType') : ''" :right-icon="canEdit ? 'arrow' : ''"
        :rules="[{ required: canEdit, message: '' }]" />
      <!-- <van-field readonly required input-align="left" label-width="4.5em"
                name="purchaseWay" :value="fromdata.purchaseWay" label="采购方式:"
                 />   -->
      <van-field readonly required name="purchaseWay" :value="fromdata.purchaseWay" label="采购方式：" label-width="5em"
        placeholder="请选择" @click="canEdit ? showOptionDialog('purchaseWayType') : ''" :right-icon="canEdit ? 'arrow' : ''"
        :rules="[{ required: canEdit, message: '' }]" />
      <!-- <van-field readonly required input-align="left" label-width="4.5em"
                name="supportContent" :value="fromdata.supportContent" label="支撑内容:" /> -->
      <myvan_field :canEdit="canEdit" :required='true' :name='"supportContent"' :model='fromdata.supportContent'
        :label='"支撑内容:"' @freshData='freshData($event)' :type='"textarea"' :placeholder='"请填写支撑内容"' />
      <!-- <van-field readonly input-align="left" label-width="4.5em"
                name="demandPrgency" :value="fromdata.demandPrgency" label="紧急程度:"/> -->
      <van-field readonly required name="demandPrgency" :value="fromdata.demandPrgency" label="紧急程度：" label-width="5em"
        :right-icon="canEdit ? 'arrow' : ''" @click="canEdit == true ? showDemandPrgencyPop = true : ''" placeholder="请选择紧急程度"
        :rules="[{ required: canEdit, message: '' }]" />
      <van-popup v-model='showDemandPrgencyPop' round position="bottom" get-container="body">
        <van-picker show-toolbar title="请选择" @cancel="showDemandPrgencyPop = false" :columns="demandPrgencyColumns"
          @confirm="demandPrgencyConfirm" />
      </van-popup>
      <van-field readonly input-align="left" label-width="6.5em" name="demandApplicationDate"
        :value="fromdata.demandApplicationDate" label="方案申请时间:" />
      <!-- <van-field readonly input-align="left" label-width="8.5em"
                name="managerArrivalTime" :value="fromdata.managerArrivalTime" label="方案期望完成时间:"/> -->
      <van-field readonly name="braceApplicationDate" :value="fromdata.braceApplicationDate" label="方案期望完成时间："
        label-width="9em" placeholder="请选择" @click="canEdit ? showDateDialog = true : ''" :right-icon="canEdit ? 'arrow' : ''" />
      <van-field readonly input-align="left" label-width="8.5em" name="braceResponseDate"
        :value="fromdata.braceResponseDate" label="方案最晚响应时间:" />
      <div v-if="showChengban == true">
        <div class="mt10" style=" display: flex;border-bottom: 1px solid #ebedf0;">
          <div class="blue_item"></div>
          <span class="font15" style="display: flex; line-height: 33px;margin-left:5px;  flex:1;">售前支撑</span>
        </div>
        <van-field readonly required input-align="left" label-width="9.5em" name="isSupport"
          :value="(fromdata.isSupport == true) ? '是' : '否'" label="是否需要省公司支撑:" />
        <van-field v-if="(fromdata.isSupport == true)" readonly required input-align="left" label-width="7.5em"
          name="provinceSupport" :value="fromdata.provinceSupport" label="省公司支撑处室:" />
        <van-field readonly input-align="left" label-width="4.5em" name="supportIndustryType"
          :value="fromdata.supportIndustryType" label="行业类型:" />
        <van-field readonly input-align="left" label-width="6.5em" name="supportPartner"
          :value="fromdata.supportPartner" label="支撑合作伙伴:" />
        <van-field readonly input-align="left" label-width="6.5em" name="isApply"
          :value="(fromdata.isApply == true) ? '是' : '否'" label="在线资质申请:" />
        <van-field v-if="fromdata.isApply == true" readonly input-align="left" label-width="6.5em"
          name="tenderProjectName" :value="fromdata.tenderProjectName" label="招标项目名称:" />
        <van-field v-if="fromdata.isApply == true" readonly input-align="left" label-width="4.5em" name="watermark"
          :value="fromdata.watermark" label="水印内容:" />
        <van-field v-if="fromdata.isApply == true" readonly input-align="left" label-width="3.5em" name="tenderee"
          :value="fromdata.tenderee" label="招标人:" />
        <van-field readonly input-align="left" label-width="2.5em" name="finallyResult" :value="fromdata.finallyResult"
          label="备注:" />
        <!-- <van-field readonly input-align="left" label-width="4.5em"
                  name="visitDescription" :value="fromdata.visitDescription" label="支撑方案:"/> -->
        <van-field label-width="10em" readonly label="支撑方案:" class="lyy-width" input-align="left" placeholder="">
        </van-field>
        <div v-for="(fileitem) in fromdata.supportProgramList" :key="fileitem.id" style="margin-left:20px">
          <div readonly class="font14 fileLink" style="color:#0F85CF">
            <a target="_blank" @click="openFileUrlfun(fileitem.anonymousFilePath)">{{ fileitem.fileName }}</a>
          </div>
        </div>
        <div v-if="fromdata.isApply == true" class="mt10" style=" display: flex;border-bottom: 1px solid #ebedf0;">
          <div class="blue_item"></div>
          <span class="font15" style="display: flex; line-height: 33px;margin-left:5px;  flex:1;">资质库关联表</span>
        </div>
        <div v-if="fromdata.isApply == true" class="mb10">
          <div v-for="(item, index) in fromdata.qualiConnect" :key="index">
            <div class="mt10 titletext pl10 font14">
              <span>资质证照名称:</span>
              <span class="titletext">{{ item.certificateName }}</span>
            </div>
            <div class="mt5 graytext pl10 font12">
              <span>持证方:</span>
              <span class="titletext">{{ item.certificateComp }}</span>
            </div>
            <div class="mt5 graytext pl10">
              <span>证书编号:</span>
              <span class="titletext">{{ item.certificateNumb }}</span>
            </div>
            <div class="mt5 graytext pl10">
              <span>证书类型:</span>
              <span class="titletext">{{ item.certificateType }}</span>
            </div>
            <div class="mt5 graytext pl10 border-b-1 pb5">
              <span>资质水印件:</span>
              <span class="color-theme">{{ item.filePdfList[0].fileName }}</span>
            </div>
          </div>
        </div>
      </div>
      <div v-if="isdrawType" style="padding-bottom: 42px"> </div>
      <van-popup v-model="showPopup" position="bottom" get-container="#app">
        <van-picker visible-item-count="6" show-toolbar :columns="typeColumns" @confirm="showConfirm"
          @cancel="showPopup = false" />
      </van-popup>
      <van-popup v-model="showDateDialog" position="bottom" get-container="#app">
        <van-datetime-picker :formatter="formatter" type="date" v-model="nowDate" :min-date="strDate"
          :max-date="maxDate" @cancel="showDateDialog = false" @confirm="showDateDialogComfirm" />
      </van-popup>
      <div v-if="!isdrawType" class="left_botton">
        <button block type="button" @click="tomsg()" style="color:#60a9ec; display: inline-block;width:100%;border: 0px solid #60a9ec;border-radius: 15px 0px 0px 15px;
            padding:10px 10px 10px 15px;font-size:13px">意见</button>
      </div>
      <div v-if="todotype || toread || isdrawType" class="footer">
        <van-button block type="info" native-type="submit" :disabled="canToNext == true ? false : true"
          style="display: inline-block;width:100%;border: 0px solid #60a9ec;">{{ toNextValue }}</van-button>
      </div>
    </van-form>
    <div v-if="showHistory" class="spline"></div>
    <van-field readonly center v-if="showHistory" label="当前办理人:" label-width="5.5em" />
    <div v-if="showHistory" class="font13 ptandpb10 pl16">
      <div>
        <span class="titletext font13">{{ historydata.MANAGER }}</span>
      </div>
      <div class="mt5">
        <span class="graytext font12 ">{{ historydata.DEPARTMENT }}</span>
      </div>
    </div>
    <div class="spline"></div>
    <div v-if="!isdrawType" style="padding-bottom: 42px">
      <div class="stitle font14" id='target'>审批意见</div>
      <div v-if="approveList.length > 0" class="swrap" style="width: 100%">
        <div class="spiece_flex" v-for="(item, index) in approveList" :key="index">
          <div class="vertical-a-t display-ib" style="width: 25px">
            <i v-if="index == 0" class="iconfont icon-current font16 color-red2"></i>
            <i v-if="index > 0" class="iconfont icon-yiban font16 color-theme"></i>
            <div v-if="index != (approveList.length - 1)" class="optionline"></div>
          </div>
          <div class="vertical-a-t display-ib" style="width: calc(100%)">
            <div style="white-space: nowrap">
              <span class="color-theme font14">{{ item.producerName || "暂无" }}：</span>
              <span class="color-2 font14">{{
      item.content || "暂无"
    }}</span>
            </div>
            <div class="mt05 color-8" style="display: flex; align-items: baseline">
              <div class="display-ib vertical-a-t font12" style="margin-top: 2px;width: 100%">
                {{ item.companyName + '-' + item.departmentName || "暂无" }}
              </div>
              <div class="display-ib vertical-a-t font12 text-r"
                style="margin-left: 10px; margin-top: 2px;text-align: right;width: 100%">
                {{ item.modifiedTime || "暂无" }}
              </div>
            </div>
          </div>
        </div>
      </div>
      <div v-else>
        <div class="color-9 font12 text-c">暂无数据</div>
      </div>
    </div>
  </div>
</template>

<script>
import myvan_field from '@/components/myvanfield';
import {
  getFormDetail, getSupportByPmInsId,
  getWfOptMags, getWfLinkTracks, getDictList
} from '@/api/dictapi'
import { mapGetters } from "vuex"
import { Notify, Dialog, Toast } from 'vant'
import moment from 'moment'
import util from "@/assets/js/public";
import { openFileUrl } from '@/store/openFile'
export default {
  components: {
    myvan_field
  },
  data() {
    return {
      titledata: {
      },
      fromdata: {
      },
      params: this.$route.query,
      todotype: false,
      approveList: [],
      showHistory: false,
      historydata: {},
      toread: false,
      showtimedialog: false,
      nowDate: new Date(new Date().getFullYear(), new Date().getMonth(), new Date().getDate(), new Date().getHours(), new Date().getMinutes()),
      strDate: new Date(new Date().getFullYear() - 10, new Date().getMonth(), new Date().getDate()),
      maxDate: new Date(new Date().getFullYear() + 10, new Date().getMonth(), new Date().getDate()),
      belongCompanyTypeDictValue: '',
      toNextValue: '流转下一步',
      canToNext: true,
      showChengban: false,
      canEdit: false,
      isdrawType: false,
      sjlistdata: {},
      ztnllistdata: {},
      dsjcplistdata: {},
      showPopColumns: ['是', '否'],
      showPop: false,
      popType: '',
      demandPrgencyColumns: ['紧急', '一般', '重要'],
      showDemandPrgencyPop: false,
      showPopup: false,
      typeColumns: [],
      optionType: '',
      showDateDialog: false
    }
  },
  computed: {
    ...mapGetters(['user']),
    ...mapGetters(['userinfo'])
  },
  //生命周期--创建完成
  created() {
    console.log('todoType2:' + this.params.todoType)
    console.log('用户信息', JSON.stringify(this.userinfo))
    if (this.params.isdraw == '1') {
      this.todotype = true;
      this.canEdit = true
      this.isdrawType = true
      this.fromdata.informantDepartment = this.userinfo.belongCompanyName + "\\" + this.userinfo.belongDepartmentName + "\\" + this.userinfo.belongOrgName
      this.fromdata.informantPosition = this.userinfo.authPositions[0].positionName
      this.fromdata.supportType = "方案支撑"
      //responseTime  solutionTime
      let demandApplicationDate = new Date(new Date().getFullYear(), new Date().getMonth(), new Date().getDate(), 0, 0, 0)
      let braceResponseDate = new Date(new Date().getFullYear(), new Date().getMonth(), new Date().getDate(), 0, 0, 0)
      braceResponseDate = braceResponseDate.setDate(braceResponseDate.getDate() + 7);
      this.fromdata.demandApplicationDate = moment(demandApplicationDate).format('YYYY-MM-DD')
      this.fromdata.braceResponseDate = moment(braceResponseDate).format('YYYY-MM-DD')
      this.fromdata.abilityInformationState = false
      this.fromdata.abilityPrecipitate = false
      this.fromdata.bigDataProductsState = false
    } else if (this.params.todoType == '1') {
      this.todotype = true;
      // if(this.params.location=='dict.startToSolutionManager'){
      //   this.canEdit=true
      // }
      if (this.params.location == 'dict.start') {
        // this.canToNext=false
        // this.toNextValue='暂不支持该环节,请至PC端办理'
        this.canEdit = true
      } else {
        this.canToNext = true
        this.toNextValue = '流转下一步'
      }
    } else if (this.params.todoType == '2') {
      this.showHistory = true;
    } else if (this.params.todoType == '3') {
      this.toread = true;
    }
    console.log('this.showHistory', this.showHistory)
    this.getdetail();
  },
  activated() {
    if (localStorage.getItem('xcsjlistdata') != '{}' && localStorage.getItem('xcsjlistdata')) {
      this.sjlistdata = JSON.parse(localStorage.getItem('xcsjlistdata'))
      this.fromdata.opportunitiesNumber = this.sjlistdata.businessId
      this.fromdata.opportunitiesName = this.sjlistdata.businessName
      this.fromdata.cities = this.sjlistdata.city
      this.fromdata.county = this.sjlistdata.county
      this.fromdata.informant = (this.sjlistdata.mgrName != null && this.sjlistdata.mgrName != 'null') ? this.sjlistdata.mgrName : ''
      this.fromdata.informantPhone = (this.sjlistdata.mgrBill != null && this.sjlistdata.mgrBill != 'null') ? this.sjlistdata.mgrBill : ''
      this.fromdata.currentSituation = this.sjlistdata.currentSituation
      this.fromdata.dictIntroduction = this.sjlistdata.projectDesc
      this.fromdata.buildContent = this.sjlistdata.projectDesc
      this.fromdata.industryType = this.sjlistdata.industryType
      this.fromdata.withBusiness = this.sjlistdata.withBusiness
      this.fromdata = JSON.parse(JSON.stringify(this.fromdata));
      localStorage.setItem('xcsjlistdata', '{}')
    } else if (localStorage.getItem('ztnllistdata') != '{}' && localStorage.getItem('ztnllistdata')) {
      this.ztnllistdata = JSON.parse(localStorage.getItem('ztnllistdata'))
      if (!this.fromdata.abilityInformationModeList) {
        this.fromdata.abilityInformationModeList = []
      }
      this.fromdata.abilityInformationModeList.push(this.ztnllistdata)
      this.fromdata = JSON.parse(JSON.stringify(this.fromdata));
      localStorage.setItem('ztnllistdata', '{}')
    } else if (localStorage.getItem('dsjcplistdata') != '{}' && localStorage.getItem('dsjcplistdata')) {
      this.dsjcplistdata = JSON.parse(localStorage.getItem('dsjcplistdata'))
      if (!this.fromdata.bigDataProductsModeList) {
        this.fromdata.bigDataProductsModeList = []
      }
      this.fromdata.bigDataProductsModeList.push(this.dsjcplistdata)
      this.fromdata = JSON.parse(JSON.stringify(this.fromdata));
      localStorage.setItem('dsjcplistdata', '{}')
    }
  },
  //生命周期--挂载完成
  mounted() {

  },
  //方法调用
  methods: {
    freshData(value) {
      console.log("W" + value.name + "E" + value.data)
      this.fromdata[value.name] = value.data
    },
    tomsg() {
      document.getElementById('target').scrollIntoView({ behavior: 'smooth' })
    },
    openFileUrlfun(value) {
      this.$router.push(
        {
          name: 'fileview',
          query: {
            openFileUrl: openFileUrl(value)
          }
        }
      );
    },
    formatter(type, val) {
      if (type === 'year') {
        return `${val}年`;
      } else if (type === 'month') {
        return `${val}月`;
      } else if (type === 'day') {
        return `${val}日`;
      } else if (type === 'hour') {
        return `${val}时`;
      } else if (type === 'minute') {
        return `${val}分`;
      }
      return val;
    },
    showtimedialogcomfirm(value) {
      this.showtimedialog = false;
      this.fromdata.visitReplyTime = moment(value).format('YYYY-MM-DD HH:mm:ss')
    },
    getdetail() {
      Toast.loading({
        message: '加载中',
        forbidClick: false
      });
      getFormDetail(Object.assign(this.params, { userName: this.user.userName }))
        .then((result) => {
          this.fromdetal = {};
          Toast.clear();
          if (!result.data) {
            Notify(result.message);
            return;
          }
          if (result.data.data) {
            this.titledata = result.data.data;
            this.belongCompanyTypeDictValue = result.data.data.belongCompanyTypeDictValue
            //省公司除起草环节外展示
            //市公司、县公司只有归档展示 this.titledata.belongCompanyTypeDictValue
            // if(result.data.data.belongCompanyTypeDictValue=='01'&&this.params.location!='dict.start'){
            //   this.showChengban=true;
            //   if(this.todotype==true){
            //     Dialog.alert({
            //       title: '提示',
            //       message: '如需调整售前支撑信息，请至PC端办理',
            //     }).then(() => {
            //       // on close
            //     });
            //   }
            // }
            if (this.params.location != 'dict.start' && this.params.location != 'dict.toStart') {
              if (this.userinfo.belongDepartmentName == '重要客户中心' || this.userinfo.belongDepartmentName == '行业客户拓展中心') {
                if (this.userinfo.belongOrgName == '项目支撑室') {
                  this.showChengban = true;
                } else {
                  this.showChengban = false;
                }
              } else if (this.userinfo.belongCompanyTypeDictValue != '03') {
                this.showChengban = true;
              } else {
                this.showChengban = false;
              }
            }

            console.log("1111111111" + result.data.data.belongCompanyTypeDictValue)
            if (result.data.data.belongCompanyTypeDictValue == '01') {
              this.showChengban = false;
            } else if ((result.data.data.belongCompanyTypeDictValue == '02' ||
              result.data.data.belongCompanyTypeDictValue == '03') && this.params.location != 'dict.toStart') {
              // this.showChengban=true;
              if (this.todotype == true && this.showChengban == true) {
                Dialog.alert({
                  title: '提示',
                  message: '如需调整售前支撑信息，请至PC端办理',
                }).then(() => {
                  // on close
                });
              }
            } else if ((result.data.data.belongCompanyTypeDictValue == '02' || result.data.data.belongCompanyTypeDictValue == '03') && this.params.location == 'dict.toStart') {
              this.showChengban = true;
            }
          }
          this.getSupportByPmInsId();
        })
    },
    getSupportByPmInsId() {
      getSupportByPmInsId(Object.assign(this.params, { userName: this.user.userName }))
        .then((result) => {
          this.fromdetal = {};
          Toast.clear();
          if (!result.data) {
            Notify(result.message);
            return;
          }
          if (result.data.data) {
            this.fromdata = result.data.data;
          }
          this.getWfOptMags();
        })
    },
    getWfOptMags() {
      getWfOptMags(Object.assign(this.params), { userName: this.user.userName })
        .then((result) => {
          Toast.clear();
          if (!result.data) {
            Notify(result.message);
            return;
          }
          this.approveList = result.data.data.reverse();
          console.log('this.showHistory222', this.showHistory)
          if (this.showHistory == true) {
            this.getWfLinkTracks()
          }
        })
    },
    getWfLinkTracks() {
      getWfLinkTracks(Object.assign(this.params), { userName: this.user.userName })
        .then((result) => {
          Toast.clear();
          if (!result.data) {
            Notify(result.message);
            return;
          }
          if (result.data.data) {
            //数据过滤，并生成新的数组
            this.historydata = result.data.data.filter(item => item.CURRENTSTATE == 10)[0]
            if (this.historydata) {
              if (this.historydata.MANAGER) {
                this.showHistory = true;
              } else {
                this.showHistory = false;
              }
            } else {
              this.showHistory = false;
            }
          } else {
            this.showHistory = false;
          }
        })
    },

    // 流转下一步
    onNext() {
      var formSendData = { "htmlParamMap": {} };
      formSendData.htmlParamMap = this.fromdata;
      if (this.fromdata.abilityInformationState == true) {
        formSendData.htmlParamMap.abilityInformationState = 'true'
      } else {
        formSendData.htmlParamMap.abilityInformationState = 'false'
      }
      if (this.fromdata.abilityPrecipitate == true) {
        formSendData.htmlParamMap.abilityPrecipitate = 'true'
      } else {
        formSendData.htmlParamMap.abilityPrecipitate = 'false'
      }
      if (this.fromdata.bigDataProductsState == true) {
        formSendData.htmlParamMap.bigDataProductsState = 'true'
      } else {
        formSendData.htmlParamMap.bigDataProductsState = 'false'
      }
      if (this.fromdata.abilityInformationModeList) {
        formSendData.htmlParamMap.abilityInformationMapList = this.fromdata.abilityInformationModeList
      }
      if (this.fromdata.bigDataProductsModeList) {
        formSendData.htmlParamMap.bigDataProductsMapList = this.fromdata.bigDataProductsModeList
      }
      formSendData.id = this.titledata.id;
      formSendData.pmInsId = this.titledata.pmInsId;
      formSendData.processType = this.params.pmInsType
      formSendData.workItemId = this.params.workItemId;
      this.titledata.belongCompanyTypeDictValue
      console.log("传给递交页面:", this.params)
      var isSupportModel = false
      if (this.fromdata.isSupport == true) {
        isSupportModel = true
      } else {
        isSupportModel = false
      }
      var params1 = {
        belongCompanyTypeDictValue: this.titledata.belongCompanyTypeDictValue,
        kv: {
          currentUserCode: util.encrypt(this.params.userName),
          source: 'MOBILE',
          location: this.params.location,
          processInstId: this.params.processInstId,
          processDefName: this.params.processDefName,
          processType: this.params.pmInsType,
          isClaimFun: '3',
          isClaimCounty: '3',
          isOperateCity: '3',
          isOperateCounties: '3',
          isProvinceConfirm: '3',
          isCityConfirm: '3',
          isSupport: isSupportModel,
        },
        body: {
          location: this.params.location,
          processInstId: this.params.processInstId,
          processDefName: this.params.processDefName,
        }
      };
      var params2 = {
        kv: {
          "currentUserCode": util.encrypt(this.params.userName),
          "source": 'MOBILE',
          "location": this.params.location,
          "processInstId": this.params.processInstId,
          'processType': this.params.pmInsType,
          'receiptCode': this.params.processInstId,
          'provinceSupport': this.fromdata.provinceSupport,
          'isOperateCity': '3',
          'isOperateCounties': '3',
        },
      };
      var params3 = {
        kv: {
          "source": 'MOBILE',
          "currentUserCode": util.encrypt(this.params.userName),
          "workItemId": this.params.todoType == 3 ? "" : this.params.workItemId,
          "processInstId": this.params.processInstId,
          "location": this.params.location,
          "notificationId": this.params.todoType == 3 ? this.params.wfnid : ""
        },
      };
      localStorage.setItem('submitPageParam', JSON.stringify({
        getDecisionsUrl: 'decisionAndUser$api$getDecisions',
        getDecisionsParams: params1,
        getUserUrl: 'decisionAndUser$api$getOrgAndUser',
        getUserParams: params2,
        tosubmintUrl: 'applicationFormEnhance$api$startSubmitProcess',
        tosubmintParams: params3,
        formData: formSendData,
        fromMoa: this.params.fromMoa,
        type: this.params.todoType == 3 ? "toRead" : "toDo"
      }));
      this.$router.push(
        {
          name: 'srqrsubmit'
        }
      );
    },

    changeFromData() {
      //提交流转
      if (this.fromdata.informantPhone != null && this.fromdata.informantPhone != '') {
        const phonePass = this.newUtils.isPhoneNumber(this.fromdata.informantPhone)
        if (!phonePass) return;
      }
      console.log("formDataformData", this.fromdata.abilityInformationState);

      this.controlRule(this.params, this.fromdata.projectID, function () {
        this.onNext();
      }.bind(this));

    },
    choseSJ() {
      this.$router.push(
        {
          name: 'seletesjlist',
          query: {
            seleteType: 'fazc'
          }
        }
      );
    },
    choseZTNL() {
      this.$router.push(
        {
          name: 'seletesjlist',
          query: {
            seleteType: 'ztnl'
          }
        }
      );
    },
    choseDSJCP() {
      this.$router.push(
        {
          name: 'seletesjlist',
          query: {
            seleteType: 'dsjcp'
          }
        }
      );
    },
    showPopView(value) {
      this.popType = value
      this.showPop = true
    },
    UpAndDownPopConfirm(value) {
      if (value == '是') {
        this.fromdata[this.popType] = true
      } else if (value == '否') {
        this.fromdata[this.popType] = false
      }
      this.showPop = false
    },
    handleDelete(index) { //delete from data
      Dialog.confirm({
        title: '提示',
        message: '是否删除此条能力信息？'
      }).then(() => {
        this.fromdata.abilityInformationModeList.splice(index, 1)
      })
        .catch(() => {
        })
    },
    demandPrgencyConfirm(value) {
      this.fromdata.demandPrgency = value
      this.showDemandPrgencyPop = false
    },
    handleDeletedsj(index) { //delete from data
      Dialog.confirm({
        title: '提示',
        message: '是否删除此条大数据产品信息？'
      }).then(() => {
        this.fromdata.bigDataProductsModeList.splice(index, 1)
      })
        .catch(() => {
        })
    },
    showOptionDialog(type) {
      this.optionType = type
      getDictList(type, { userName: this.user.userName })
        .then((result) => {
          if (!result.data) {
            Notify(result.message);
            return;
          }
          this.typeColumns = [];
          for (var i = 0; i < result.data.data.length; i++) {
            this.typeColumns.push(result.data.data[i].name);
          }
          this.showPopup = true;
        })
    },
    showConfirm(value) {
      if (this.optionType == 'supportWayType') {
        this.fromdata.supportWay = value
      } else if (this.optionType == 'purchaseWayType') {
        this.fromdata.purchaseWay = value
      }
      this.showPopup = false
    },
    showDateDialogComfirm(value) {
      this.fromdata.braceApplicationDate = moment(value).format('YYYY-MM-DD');
      this.showDateDialog = false;
    }
  }
}
</script>
<style scoped>
/* @import url();*/
</style>